package org.bilinc.gz001;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
import java.util.*;
import java.util.List;

public class WorkedRenderer extends DefaultTableCellRenderer {

    private List<Integer> mDividers;
    private static final Color FIELD_COLOR = new Color(255, 255, 204);

    public Component getTableCellRendererComponent(JTable table,
                                                   Object obj, boolean isSelected, boolean hasFocus, int row, int column) {
        final Component cell = super.getTableCellRendererComponent(
                table, obj, isSelected, hasFocus, row, column);
        if (isSelected) {

        } else {
            if (mDividers != null) {
                if (mDividers.contains(row)) {
                    cell.setBackground(Color.cyan);
                } else {
                    cell.setBackground(FIELD_COLOR);
                }
            }
        }
        return cell;
    }

    public void setDividers(final List<Integer> d) {
        if (d == null) {
            System.out.println("WorkedRenderer setDividers null");
            return;
        }
        if (!d.isEmpty()) {
            mDividers = d;
        }
    }
}